package cn.iocoder.yudao.module.order.dal.mysql.memberstream;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.order.dal.dataobject.memberstream.MemberStreamDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.order.controller.admin.memberstream.vo.*;

/**
 * 会员流水 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface MemberStreamMapper extends BaseMapperX<MemberStreamDO> {

    default PageResult<MemberStreamDO> selectPage(MemberStreamPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MemberStreamDO>()
                .eqIfPresent(MemberStreamDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(MemberStreamDO::getPhoneNumber, reqVO.getPhoneNumber())
                .eqIfPresent(MemberStreamDO::getPreviousBalance, reqVO.getPreviousBalance())
                .eqIfPresent(MemberStreamDO::getTransactionAmount, reqVO.getTransactionAmount())
                .eqIfPresent(MemberStreamDO::getCurrentBalance, reqVO.getCurrentBalance())
                .eqIfPresent(MemberStreamDO::getOrderNumber, reqVO.getOrderNumber())
                .eqIfPresent(MemberStreamDO::getBusinessType, reqVO.getBusinessType())
                .eqIfPresent(MemberStreamDO::getPaymentMethod, reqVO.getPaymentMethod())
                .eqIfPresent(MemberStreamDO::getCreatedAt, reqVO.getCreatedAt())
                .orderByDesc(MemberStreamDO::getId));
    }

    default List<MemberStreamDO> selectList(MemberStreamExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<MemberStreamDO>()
                .eqIfPresent(MemberStreamDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(MemberStreamDO::getPhoneNumber, reqVO.getPhoneNumber())
                .eqIfPresent(MemberStreamDO::getPreviousBalance, reqVO.getPreviousBalance())
                .eqIfPresent(MemberStreamDO::getTransactionAmount, reqVO.getTransactionAmount())
                .eqIfPresent(MemberStreamDO::getCurrentBalance, reqVO.getCurrentBalance())
                .eqIfPresent(MemberStreamDO::getOrderNumber, reqVO.getOrderNumber())
                .eqIfPresent(MemberStreamDO::getBusinessType, reqVO.getBusinessType())
                .eqIfPresent(MemberStreamDO::getPaymentMethod, reqVO.getPaymentMethod())
                .eqIfPresent(MemberStreamDO::getCreatedAt, reqVO.getCreatedAt())
                .orderByDesc(MemberStreamDO::getId));
    }

}
